Skip to content

feat: enable semantic versioning for openAPI specs#677

Closed
mpryahin wants to merge 5 commits into
mainfrom
mpryakhin/openapispec-semver
Closed

feat: enable semantic versioning for openAPI specs#677
mpryahin wants to merge 5 commits into
mainfrom
mpryakhin/openapispec-semver

Conversation

@mpryahin
Copy link
Copy Markdown
Contributor

@mpryahin mpryahin commented Jul 10, 2025

📝 Description

This PR adds automatic version injection to OpenAPI files during the build process. This ensures consistent automatic versioning across all components in the repository.

Changes:

  • OpenAPI specs now use $TAG placeholder for version
  • Build process replaces placeholder with actual version from TAG environment variable as for all other build artifacts

✨ Type of Change

Select the type of change your PR introduces:

  • 🐞 Bug fix – Non-breaking change which fixes an issue
  • 🚀 New feature – Non-breaking change which adds functionality
  • 🔨 Refactor – Non-breaking change which refactors the code base
  • 💥 Breaking change – Changes that break existing functionality
  • 📚 Documentation update
  • 🔒 Security update
  • 🧪 Tests

🧪 Testing Scenarios

Describe how the changes were tested and how reviewers can test them too:

  • ✅ Tested manually
  • 🤖 Run automated end-to-end tests

✅ Checklist

Before submitting the PR, ensure the following:

  • 🔍 PR title is clear and descriptive
  • 📝 For internal contributors: If applicable, include the JIRA ticket number (e.g., ITEP-123456) in the PR title. Do not include full URLs
  • 💬 I have commented my code, especially in hard-to-understand areas
  • 📄 I have made corresponding changes to the documentation
  • ✅ I have added tests that prove my fix is effective or my feature works

@github-actions github-actions Bot added documentation Improvements or additions to documentation UI IAI Interactive AI backend labels Jul 10, 2025
openapi: "3.1.0"
info:
version: 2.12.0
version: ${TAG}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BDD tests depend on openapi_internal.yaml to generate the JSON spec (source). I checked this branch and the API client auto-generation still succeeds even if the ${TAG} is not resolved in the JSON file:
image

I don't know if this has side effects on the BDD tests, though. Could you please run them on this PR?

Copy link
Copy Markdown
Contributor Author

@mpryahin mpryahin Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Leo, I've implemented an additional target that compiles the OpenAPI spec before generating a client, but given that the compiled code is generated in a subfolder, the hardcoded references to the object schemas break. So the idea of version generation will not work for this OpenAPI spec. I'm closing the PR.
image

Copy link
Copy Markdown
Contributor

@MarkRedeman MarkRedeman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to block this since it will help in improving our release process.

But I personally don't really like that we are making a functioning yaml configuration file be aware of how our build system is supposed to work.

One thing for the UI team to be aware of with this change is that running npm run build:rest-openapi-spec will no longer produce a valid spec as like Leo mentioned the version will be "${TAG}".
We could fix that by adding these env substitions into our scripts as well, but I think that would just add more complexity without a lot of gain.

Comment thread web_ui/Dockerfile
Comment on lines -46 to +57
COPY --from=docs_context rest_api /home/app/docs/rest_api/
COPY --from=api_context schemas /home/app/interactive_ai/services/api/schemas/
COPY --from=build_rest_api_specs /home/app/docs/rest_api/ /home/app/docs/rest_api/
COPY --from=build_rest_api_specs /home/app/interactive_ai/services/api/schemas/ /home/app/interactive_ai/services/api/schemas/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can remove these since we don't need this at build time (only when calling build:rest-openapi-spec).

Comment thread web_ui/Dockerfile
Comment on lines +22 to +25
RUN TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi.yaml > /home/app/docs/rest_api/openapi.yaml.tmp && \
mv /home/app/docs/rest_api/openapi.yaml.tmp /home/app/docs/rest_api/openapi.yaml && \
TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < /home/app/docs/rest_api/openapi_internal.yaml > /home/app/docs/rest_api/openapi_internal.yaml.tmp && \
mv /home/app/docs/rest_api/openapi_internal.yaml.tmp /home/app/docs/rest_api/openapi_internal.yaml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could simplify this a bit using tee,

RUN for file in /home/app/docs/rest_api/openapi.yaml /home/app/docs/rest_api/openapi_internal.yaml; do \
      TAG=${REACT_APP_GETI_VERSION} envsubst '$$TAG' < "$file" | tee "$file"; \
    done

Comment thread docs/rest_api/Makefile Outdated
@@ -0,0 +1,22 @@
include ../../Makefile.shared

RESTAPI_BUILD_DIR := ${TARGET_DIR}/rest-api
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This folder uses kebab case vs the camel case that we use in the actual folder is that intended?

@mpryahin
Copy link
Copy Markdown
Contributor Author

closing because of this issue: #677 (comment)

@mpryahin mpryahin closed this Jul 10, 2025
@mpryahin mpryahin deleted the mpryakhin/openapispec-semver branch October 6, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation IAI Interactive AI backend UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants